
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>亚马逊-首页</title>
<link href="${pageContext.request.contextPath}/css/index.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/adv.css"
	rel="stylesheet" type="text/css" />
<script src="${pageContext.request.contextPath}/scripts/jquery-2.1.0.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/scripts/adv.js"
	type="text/javascript"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/scripts/function.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/scripts/index.js"></script>

	<script>
		$(function () {
			ShowAll(1,12);
			DOubleIN();
		});

			function ShowAll(pageNo, pageSize){
			$.post("${pageContext.request.contextPath}/news",{
				"param":"proList",
						"pageNo": pageNo,
						"pageSize": pageSize
					}
					,function (data) {
						$ul=$(".product2");
						$ul.empty();

				for (var i = 0; i < data.list.length; i++) {
					var $li=$("<li></li>");
					var $dl=$("<dl></dl>");
					$(".product2").append($li);
					$li.append($dl);
					var $dt=$("<dt><a href='${pageContext.request.contextPath}/product?param=shop&id="+data.list[i].id+"' target='_self'><img src='"+data.list[i].img_source+"'/></a></dt>");
					$dl.append($dt);
					var $dd=$("<dd class='title'><a href='${pageContext.request.contextPath}/product&param=shop?id="+data.list[i].id+"' target='_self'>"+data.list[i].name+"</a></dd>");
					$dl.append($dd);
					var $dd1=$("<dd class='price'><a href='${pageContext.request.contextPath}/product&param=shop?id="+data.list[i].id+"' target='_self'>￥"+data.list[i].price+"</a></dd>");
					$dl.append($dd1);
				}
						/*-------------------------------------------------------------------------------------------------------*/
						$a = $(".page>a");
						$a.eq(0).attr("href", "javascript:ShowAll('" + 1 + "','" + pageSize + "')");
						$a.eq(1).attr("href", "javascript:ShowAll('" + data.prePage + "','" + pageSize + "')");
						$a.eq(2).attr("href", "javascript:ShowAll('" + data.nextPage + "','" + pageSize + "')");
						$a.eq(3).attr("href", "javascript:ShowAll('" + data.totalPages + "','" + pageSize + "')");
						$span = $(".page>span");
						$span.eq(0).html(data.pageNo);
						$span.eq(1).html(data.totalPages);
					}, "json")
			}

			function DOubleIN(){
				$.post("${pageContext.request.contextPath}/news?param=showList",function (data) {
					var $prelook = $(".pre_look");
					for(var i=0;i<data.length;i++){
						var $dl = $("<dl></dl>");
						var $dt = $("<dt><img style='width: 54px; height: 54px;' src='"+data[i].img_source +"' /></dt>");
						var $dd = $("<dd><a href='')>"+data[i].name+"</a></dd>");
						$dl.append($dt);
						$dl.append($dd);
						$prelook.append($dl);
					}
				},"json");
			}
	</script>
</head>
<body>
	<%@ include file="index_top.jsp"%>
	<div id="middle">
		<div class="p_left">
			<!--商品分类-->
			<%@ include file="index_product_sort.jsp"%>
			<!--商品分类结束-->
			<div class="pre_look">
				<h3>最近浏览</h3>
			</div>
		</div>

		<div class="p_center">
			<div id="wrapper">
				<div id="focus">
					<ul>
						<li><a href="#"><img src="images/T1.jpg" /></a></li>
						<li><a href="#"><img src="images/T2.jpg" /></a></li>
						<li><a href="#"><img src="images/T3.jpg" /></a></li>
						<li><a href="#"><img src="images/T4.jpg" /></a></li>
						<li><a href="#"><img src="images/T5.jpg" /></a></li>
					</ul>
				</div>
			</div>
			<div class="p_list">
				<div class="p_info">
					<img src="images/icon_sale.png" />商品列表
				</div>
			</div>

			<ul class="product2" >
					<%--<li>
						<dl>
							<dt>
								<a href="" target="_self">
								<img src="" /></a>
							</dt>
							<dd class="title">
								<a href="" target="_self"></a>
							</dd>
							<dd class="price">￥</dd>
						</dl>
					</li>--%>
			</ul>
			<div class="page" align="center" style="margin-top:10px" >
				<a href="#">首页</a>&nbsp;&nbsp;&nbsp;
				<a href="#">上一页</a>&nbsp;&nbsp;
				<a href="#">下一页</a>&nbsp;&nbsp;
				<span></span>/<span></span>&nbsp;&nbsp;
				<a href="#">最后一页</a>
			</div>
		</div>


		<div id="p_right">
			<%@ include file="index_news.jsp"%>
			<%@ include file="hotproduct.jsp"%>
		</div>
	</div>

	<div id="foot">Copyright © 2018 上海海文 All Rights Reserved.</div>
</body>
</html>

